
#include "S_10_Enhance_doGet.h"
#include "mi_iid_define.h"
#include "property_decoder.h"
#include "section_define.h"
#include "main.h"

extern uint8_t  g_uNo1RegList[PBS_NO1REGSIZE];

/**
 * 格式: property_value_new_integer(整数)　
 * 取值: 0(Default), 1(Room1), 2(Room2), 3(Room3), 4(Room4), 5(Room5), 6(Room6)
 */
static void P_10_16_RoomSize_doGet(property_operation_t *o)
{
	InDoorBusReg RegSection1 = {0};
#if 	PROPERTY_TYPE
	RegSection1.V8 = GetPbsRegValue(0x1F);
//	if(RegSection1.BIT1.bit7)
	{
		property_value_new_integer(&o->value,RegSection1.BIT1.bit0_6);
	}	
	
#else	
	o->value.format = PROPERTY_FORMAT_NUMBER;
	o->value.data.number.type = DATA_NUMBER_INTEGER;
	o->value.data.number.value.integerValue = 2;// TODO: 这里需要读到属性真正的值
#endif
    
}

/**
 * 格式: property_value_new_integer(整数)　
 * 取值: 最小值: 0, 最大值: 101, 步长: 1
 */
static void P_10_1_FanPercent_doGet(property_operation_t *o)
{
	InDoorBusReg RegSection1= {0};
#if 	PROPERTY_TYPE
	RegSection1.V8 = GetPbsRegValue(0x1B);
//	if(RegSection1.BIT1.bit7)
	{
		property_value_new_integer(&o->value,RegSection1.BIT1.bit0_6);
	}
	
#else	
	o->value.format = PROPERTY_FORMAT_NUMBER;
	o->value.data.number.type = DATA_NUMBER_INTEGER;
	o->value.data.number.value.integerValue = 66; // TODO: 这里需要读到属性真正的值
#endif
    
}

/**
 * 格式: property_value_new_boolean(true 或 false)　
 * 取值: true 或　false
 */
static void P_10_18_MaxfanSelect_doGet(property_operation_t *o)
{
	InDoorBusReg RegSection1= {0};
#if 	PROPERTY_TYPE
	RegSection1.V8 = GetPbsRegValue(0x03);
//	if(RegSection1.BIT.bit7)
	{
		property_value_new_boolean(&o->value,RegSection1.BIT.bit6);
	}
	
#else	
	o->value.format = PROPERTY_FORMAT_BOOLEAN;
    o->value.data.boolean.value = true;  // TODO: 这里需要读到属性真正的值
#endif
    
}

/**
 * 格式: property_value_new_string(字符串)　
 * 取值: 字符串，没有限制取值范围
 */
static void P_10_3_Timer_doGet(property_operation_t *o)
{
	InDoorBusReg RegSection1 = {0};
	char Str[16] = {0};
#if 	PROPERTY_TYPE
	RegSection1.V8 = GetPbsRegValue(0x2D);
//	if(RegSection1.V8)
	{
		sprintf(Str,"%d,%d,%d,%d",g_uNo1RegList[0x2E],((g_uNo1RegList[0x30]<<8)|(g_uNo1RegList[0x2F])),g_uNo1RegList[0x31],((g_uNo1RegList[0x33]<<8) |g_uNo1RegList[0x32]));//定时	
	}
	property_value_new_string(&o->value,Str);
#else	
	o->value.format = PROPERTY_FORMAT_STRING;
	strncpy(o->value.data.string.value, "hello", strlen("hello")); // TODO: 这里需要读到属性真正的值
	o->value.data.string.length = strlen("hello"); // TODO: 这里需要读到属性真正的值
#endif
    
}

/**
 * 格式: property_value_new_boolean(true 或 false)　
 * 取值: true 或　false
 */
static void P_10_19_RoomSelect_doGet(property_operation_t *o)
{
	InDoorBusReg RegSection1= {0};
#if 	PROPERTY_TYPE
	RegSection1.V8 = GetPbsRegValue(0x03);
//	if(RegSection1.BIT.bit1)
	{
		property_value_new_boolean(&o->value,RegSection1.BIT.bit0);
	}
	
#else	
	o->value.format = PROPERTY_FORMAT_BOOLEAN;
    o->value.data.boolean.value = true;  // TODO: 这里需要读到属性真正的值
#endif
    
}

/**
 * 格式: property_value_new_boolean(true 或 false)　
 * 取值: true 或　false
 */
static void P_10_4_SleepDiy_doGet(property_operation_t *o)
{
	InDoorBusReg RegSection1 = {0};
#if 	PROPERTY_TYPE
	RegSection1.V8 = GetPbsRegValue(0x06);
//	if(RegSection1.BIT.bit3)
	{
		property_value_new_boolean(&o->value,RegSection1.BIT.bit2);
	}
	
#else	
	o->value.format = PROPERTY_FORMAT_BOOLEAN;
    o->value.data.boolean.value = true;  // TODO: 这里需要读到属性真正的值
#endif
    
}

/**
 * 格式: property_value_new_boolean(true 或 false)　
 * 取值: true 或　false
 */
static void P_10_20_LikeDiy_doGet(property_operation_t *o)
{
//	InDoorBusReg RegSection1 = {0};
#if 	PROPERTY_TYPE
//	RegSection1.V8 = GetPbsRegValue(0x06);
//	if(RegSection1.BIT.bit1)
	{
//		property_value_new_boolean(&o->value,RegSection1.BIT.bit0);
	}
	
#else	
	o->value.format = PROPERTY_FORMAT_BOOLEAN;
    o->value.data.boolean.value = true;  // TODO: 这里需要读到属性真正的值
#endif
   
}

void S_10_Enhance_doGet(property_operation_t *o)
{
    switch (o->piid)
    {
        case PIID_10_16_RoomSize:
            P_10_16_RoomSize_doGet(o);
            break;

        case PIID_10_1_FanPercent:
            P_10_1_FanPercent_doGet(o);
            break;

        case PIID_10_18_MaxfanSelect:
            P_10_18_MaxfanSelect_doGet(o);
            break;

        case PIID_10_3_Timer:
            P_10_3_Timer_doGet(o);
            break;

        case PIID_10_19_RoomSelect:
            P_10_19_RoomSelect_doGet(o);
            break;

        case PIID_10_4_SleepDiy:
            P_10_4_SleepDiy_doGet(o);
            break;

        case PIID_10_20_LikeDiy:
            P_10_20_LikeDiy_doGet(o);
            break;

        default:
            o->code = OPERATION_ERROR_VALUE;
            break;
    }
}
